package me.himi.love.im.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class CommonUtils {

    /** ����Ƿ������� */
    public static boolean isNetworkAvailable(Context context) {
	NetworkInfo info = getNetworkInfo(context);
	if (info != null) {
	    return info.isAvailable();
	}
	return false;
    }

    /** ����Ƿ���WIFI */
    public static boolean isWifi(Context context) {
	NetworkInfo info = getNetworkInfo(context);
	if (info != null) {
	    if (info.getType() == ConnectivityManager.TYPE_WIFI)
		return true;
	}
	return false;
    }

    /** ����Ƿ����ƶ����� */
    public static boolean isMobile(Context context) {
	NetworkInfo info = getNetworkInfo(context);
	if (info != null) {
	    if (info.getType() == ConnectivityManager.TYPE_MOBILE)
		return true;
	}
	return false;
    }

    private static NetworkInfo getNetworkInfo(Context context) {

	ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	return cm.getActiveNetworkInfo();
    }

    /** ���SD���Ƿ���� */
    public static boolean checkSdCard() {
	if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
	    return true;
	return false;
    }

}
